package com.lhd.struct.facade;

/**
 * @Author: liuhd
 * @Date: 2024/10/27 22:31
 * @Description: 外观角色
 */
public class SmartApplicationFacade {
    private Light light;
    private TV tv;
    private AirCondition airCondition;
    public SmartApplicationFacade(){
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }
    public void say(String msg) {
        if (msg.contains("打开")) {
            on();
            return;
        }
        if (msg.contains("关闭")) {
            off();
            return;
        }
        System.out.println("暂时无法识别");
    }

    private void on() {
        light.on();
        tv.on();
        airCondition.on();
    }

    private void off() {
        light.off();
        tv.off();
        airCondition.off();
    }
}
